<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class home extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->library('session');
        $this->load->helper('url');
        $this->load->library('form_validation');
        $this->load->library("pagination");
        $this->load->model('desa_model');
        $this->load->model('penduduk_model');
    }

    public function index() {
        $this->load->view('theme/header');
        $this->load->view('page/slider');
        $this->load->view('page/home_kependudukan');
        $this->load->view('page/home_kemiskinan');
        $this->load->view('page/home_rtrw');
        $this->load->view('page/home_kesehatan');
        $this->load->view('page/home_pendidikan');
        $this->load->view('theme/footer');
    }

    public function search_data() {
        $nik = $this->input->post('nik');

        $data["data_penduduk"] = $this->penduduk_model->get_biodata_by_nik($nik);

        $this->load->view('theme/header');
        $this->load->view('theme/sidebar');
        $this->load->view('page/searchresult', $data);
        $this->load->view('theme/footer');
    }

    public function usia() {
        $this->load->view('theme/header');
        $this->load->view('theme/sidebar');
        $this->load->view('page/usia');
        $this->load->view('theme/footer');
    }

    public function penduduk() {
        $this->load->view('theme/header');
        $this->load->view('page/wilayah');
        $this->load->view('theme/footer');
    }

    public function req_kelurahan() {
        $id_kec = $this->input->post('id_kecamatan');
        $list_kelurahan = $this->penduduk_model->get_list_kelurahan($id_kec);
        echo '<option value="0">Semua Kelurahan</option>';
        foreach ($list_kelurahan as $kel) {
            echo '<option value="' . $kel->no_kel . '">' . $kel->nama_kel . '</option>';
        }
    }

    public function get_kec_kode() {
        $kec_id = $this->input->post('kec_id');
        $q = $this->penduduk_model->get_kec_kode($kec_id);
        $res = array();
        $res['id']=0;
        //var_dump($q);
        if (count($q) > 0)
            $res['id'] = $q->kec_kode;
        echo json_encode($res);
    }

}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */